package other_其他模式.intercepting_filter_pattern_拦截过滤器模式;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/10/13:58
 * @Description:
 */
public class FilterChain {
	private List<Filter> filters = new ArrayList<>();

	private Target target;

	public void setTarget(Target target) {
		this.target = target;
	}

	public void addFilter(Filter filter) {
		filters.add(filter);
	}

	public void execute(String request) {
		filters.forEach(filter -> filter.execute(request));
		target.execute(request);
	}
}
